<?php
/**
 * Created by PhpStorm.
 * User: 戎大富
 * Date: 2018/6/13
 * Time: 13:49
 */
namespace app\common\model;
use think\Model;

class Banner extends Model {
    protected $table='up_banner';

    private static $instance;

    /***
     * @param $pagesize
     * @return \think\Paginator
     */
    public function relData($where, $pagesize){
        $model = self::instance();
        $list = $model->alias('u')
            ->where($where)
            ->order('banner_sort asc')
            ->paginate($pagesize);
        return $list;
    }
    /***
     * @return false|\PDOStatement|string|\think\Collection
     * 查询Banner图
     */
    public function selectBanner($field){
        $model = self::instance();
        $where['banner_status'] = 1;
        $list = $model->where($where)->field($field)->order('banner_sort asc')->limit(6)->select();
        return $list;
    }
    /**
     * @param $uid
     * @param string $field
     * @return array|false|\PDOStatement|string|\think\Model
     * 获取一条信息
     */
    public function getOneS($where,$field='*'){
        $model = self::instance();
        $result = $model->where($where)->field($field)->find();
        return $result;
    }
    /**
     * @return array
     * 查询Banner一条信息记录
     */
    public function getOne($id,$field='*')
    {
        $model = self::instance();
        $where['banner_id'] = $id;
        $list = $model->where($where)->field($field)->find();
        return $list;
    }
    public static function instance()
    {
        if (!(self::$instance instanceof self)) {
            self::$instance = new self();
        }
        return self::$instance;
    }

}